package com.chinatelecom.telecollege.sellerrewarding.token;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.UUID;
/**
 * Created by lenovo on 2017/6/21.
 */
public class DefaultTokenManager implements TokenManager {
    private static Map<String, String> tokenMap = new ConcurrentHashMap<String, String>();
    public String createToken(String username) {
        UUID uuid = UUID.randomUUID();
        String token = uuid.toString();
        tokenMap.put(token, username);
        return token;
    }
    public boolean checkToken(String token) {
        return token.length()>0 && tokenMap.containsKey(token);
    }
    public String getuser(String token) {
        return tokenMap.get(token);
    }
}
